package com.study.rabbit.mqtest;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class Consumer2 {
    @RabbitListener(queues = "TestDirectQueue2")
    public void getMassage(String msg, Channel channel, Message message) throws IOException {
        System.out.println("消费者2接收到消息："+msg);
        //手动ack
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }

}

